package java.com.atguigu.springcloud.service.impl;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.com.atguigu.springcloud.service.IMessageProvider;
import java.util.UUID;

/**
 * @Author: 19shusheng.com
 * @Description:
 * @Date: Created in 19:04 2021/3/10
 * @Modified By:
 */
@EnableBinding(Source.class) //定义消息的推送管道
public class IMessageProviderImpl implements IMessageProvider {
    /**
     *
     * @Description: 消息发送管道
     *
     * @auther: madonghui
     * @date: 19:11 2021/3/10
     * @param:
     * @return:
     *
     */
    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("***serial:"+serial);
        return null;
    }
}
